﻿using System;

namespace Ayatta.Contract.Domain
{
    public class Auction : BaseEntity<int>
    {
        /// <summary>
        /// SkuId
        /// </summary>
        public int SkuId { get; set; }
        /// <summary>
        /// 商品Id
        /// </summary>
        public int ItemId { get; set; }
        /// <summary>
        /// 产品Id
        /// </summary>
        public int ProductId { get; set; }
        /// <summary>
        /// 是否为虚拟物品
        /// </summary>
        public bool IsVirtual { get; set; }
        /// <summary>
        /// 拍品等级
        /// </summary>
        public AuctionGrade Grade { get; set; }
        /// <summary>
        /// 每次出价消耗金额
        /// </summary>
        public int PerPrice { get; set; }
        /// <summary>
        /// 重置秒数
        /// </summary>
        public int Interval { get; set; }
        /// <summary>
        /// 拍品名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        public string PictureSrc { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 成本价格
        /// </summary>
        public decimal Cost { get; set; }
        /// <summary>
        /// 购买价格
        /// </summary>
        public decimal BuyPrice { get; set; }
        /// <summary>
        /// 参考价格
        /// </summary>
        public decimal MarketPrice { get; set; }
        /// <summary>
        /// 安全价格
        /// </summary>
        public decimal SafePrice { get; set; }
        /// <summary>
        /// 兑换积分(0为不可兑换积分)
        /// </summary>
        public int IntegralExchange { get; set; }
        /// <summary>
        /// 是否可补差购买
        /// </summary>
        public bool DiffBuySupported { get; set; }
        /// <summary>
        /// 可以补差购买数量的条件
        /// </summary>
        public DiffBuyLimitation DiffBuyLimitation { get; set; }
        /// <summary>
        /// 补差购买数量的条件的值
        /// </summary>
        public int DiffBuyLimitationValue { get; set; }
        /// <summary>
        /// 是否支付0元竞拍
        /// </summary>
        public bool ZeroSupported { get; set; }
        /// <summary>
        /// 是否可以使用免费拍币
        /// </summary>
        public bool FreeBidSupported { get; set; }
        /// <summary>
        /// 可以使用免费拍币的条件
        /// </summary>
        public FreeBidLimitation FreeBidLimitation { get; set; }
        /// <summary>
        /// 可以使用免费拍币的条件的值
        /// </summary>
        public int FreeBidLimitationValue { get; set; }
        /// <summary>
        /// 附加费
        /// </summary>
        public decimal AdditionalCharge { get; set; }
        /// <summary>
        /// 上架时间
        /// </summary>
        public DateTime OnlineTime { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public string StartTime { get; set; }
        /// <summary>
        /// 开始日期时间
        /// </summary>
        public DateTime StartDateTime { get { return DateTime.Parse(StartTime); } }
        /// <summary>
        /// 结束时间
        /// </summary>
        public string StopTime { get; set; }
        /// <summary>
        /// 结束日期时间
        /// </summary>
        public DateTime StopDateTime { get { return DateTime.Parse(StopTime); } }
        /// <summary>
        /// 当前价格
        /// </summary>
        public decimal BidPrice { get; set; }
        /// <summary>
        /// 当前出价用户Id
        /// </summary>
        public int UserId { get; set; }
        /// <summary>
        /// 当前用户昵称
        /// </summary>
        public string NickName { get; set; }
        /// <summary>
        /// 当前用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 预期成交时间
        /// </summary>
        public DateTime? ExpectedTime { get; set; }
        /// <summary>
        /// 实际成交时间
        /// </summary>
        public DateTime? TransactionTime { get; set; }
        /// <summary>
        /// 商家Id
        /// </summary>
        public int SellerId { get; set; }
        /// <summary>
        /// IpAddress
        /// </summary>
        public string IpAddress { get; set; }
        /// <summary>
        /// 订单Id
        /// </summary>
        public string OrderId { get; set; }
        /// <summary>
        /// 扩展信息
        /// </summary>
        public string Extra { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public AuctionStatus Status { get; set; }

        //public int Counter { get; set; }

        //public Order GenerateOrder(int userId, string userName, string nickName, string ipAddress)
        //{
        //    var time = DateTime.Now;
        //    var order = new Order {
        //        Id = Guid.NewGuid().ToString(),
        //        UserId = userId,

        //        Quantity = 1,
        //        SubTotal = BuyPrice,
        //        ShippingCharge = AdditionalCharge,
        //        Discount = 0,
        //        Total = BuyPrice + AdditionalCharge,
        //        Paid = 0,
        //        Refund = 0,
        //        Weight = 0,
        //        TraceCode = string.Empty,
        //        ShippingMethod = 0,
        //        PaymentMethod = 0,
        //        Status = OrderStatus.Pending,
        //        ShippingStatus = ShippingStatus.NotYetShipped,
        //        PaymentStatus = PaymentStatus.Pending,
        //        ExpirationTime = DateTime.Now.AddHours(2),
        //        IpAddress = ipAddress,
        //        CreatedBy = userName,
        //        CreatedOn = time
        //    };
        //    return order;
        //}
    }
}
